package com.school;

public class Test_4 {
    public static void main(String[] args) {
        Village village = new Village(500);
        Village.man man1 = village.getMan();
        Village.man man2 = village.getMan();
        man1.show();
        man1.eat(100);
        man2.show();
        man2.eat(200);
        man1.show();

    }
}

class Village{
    public static int water;

    public Village(int water) {
        this.water=water;
    }
    //定义村名
    class man{
        public void eat(int eat){
            System.out.println("我用了"+eat+"的水");
            water-=eat;
        }
        //显示剩余水量
        public void show(){
            System.out.println("水还有"+water);
        }
    }
    //获取村民
    public man getMan(){
        return  new man();
    }
}